package com.rico.queue.controller;

import com.rico.queue.common.TopicName;
import io.github.majusko.pulsar.producer.PulsarTemplate;
import org.apache.pulsar.client.api.MessageId;
import org.apache.pulsar.client.api.PulsarClientException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class PulsarController {
    @Autowired
    private PulsarTemplate template;

    @PostMapping("/sendMessage")
    public void sendMessage(String message){
        try {
            MessageId messageId=template.send(TopicName.BATCH_SYNC_NFT_PROFILE,message);
        } catch (PulsarClientException e) {
            e.printStackTrace();
        }
    }
}
